if background field "StackNameField" is empty then signature
end if
pass idle
end idle
on signature
put "by HyperPro" into background field "StackNameField"
put "19925 Stevens Creek Blvd. Cupertino, CA 95014" into background field "ObjectNameField"
show bkgnd button "hide buttons"
end signature
on emptyThis -- "this" is The Script Reader.
global whereFrom
put "read" into whereFrom
send mouseUp to bkgnd button "empty reader"
signature
end emptyThis
on learnName --gets the name of the target stack
global targetStack,totalCards,totalBacks,targetLongName,targetShortName
global thisStack --1.2
set cursor to 4
-- thisStack = the path name of the Script Reader stack
put the long name of this stack into fixName
--correcting the returned stack name to match
-- the format returned by the XCMD below.
delete word 1 of fixName --killing the word "stack" & the space
delete char 1 of fixName --killing the quote
delete last char of fixName -- killing the quote
put fixName into thisStack
get fileName ("STAK") --XCMD written by Steve Maller (Thanks!)
if it is empty then exit to hypercard -- user has cancelled
if it is thisStack then --1.2
answer "Sorry, you can only read a COPY of this stack!" --1.2
put empty into it
learnName
exit learnName
end if
set cursor to 4
put it into targetStack --1.2
put targetStack into targetLongName --saving the pathname for later
set lockMessages to true
set lockScreen to true
set lockRecent to true
push card
go to stack targetStack
put the short name of this stack into targetShortName
put the number of cards into totalCards
put the number of backgrounds into totalBacks
pop card -- Returning to paste the info & to see if you
-- want to continue
put targetLongName into field stackNameField
put "Statistics of the Stack" into field "ObjectNameField"
repeat with i = 1 to 10
--pushing the text down so it can be read under the coming alert
put return before field ScriptField
end repeat
if totalCards is 1 then --formatting the measure
put " card." into totCard
else
put " cards." into totCard
end if
if totalBacks is 1 then --formatting the measure
put " background." into totBack
else
put " backgrounds." into totBack
end if
put "Contains " & totalBacks & totBack & return after field ScriptField
put "Contains " & totalCards & totCard after field ScriptField
put return after field ScriptField
--check to see if you want to go on
set lockScreen to false
answer "Want to continue?" with "No" or "Yes"
if it is "No" or it is empty then
moveUp
cleanUp -- which exits
end if
-- you want to continue & we get ready to get scripts
moveUp
doMenu "New Card"
end learnName
on readStack
global targetStack,totalCards,totalBacks,targetLongName,thisStack
global backScripts,cardScripts,targetShortName
--thisStack is the entire pathname of Script Reader
put targetShortName into field StackNameField
put "Script of stack" into field ObjectNameField
-- now get the script, test for empty,
-- then put it in the scrolling field
set cursor to 4
get script of stack targetStack
if it is empty then put "No stack script." into it
put it into field "ScriptField"
set lockMessages to true
set lockScreen to true
push card
--================= In the target stack here ==================
go stack targetStack
readBackgrounds --gets all scripts of backgrounds & objects
readCards --gets all scripts of cards & objects
end readStack
on readBackgrounds
global targetStack,totalCards,totalBacks,targetLongName,thisStack
global backScripts,deLim1,deLim2,targetShortName
--============== getting the background scripts =============
makeDeLim -- creates the delimiters
put empty into backgndName --initializing the variable
put "Quietly loading scripts into RAM. This may take a while..."
repeat with i = 1 to totalBacks
go card 1 of bkgnd i
cursorwatch
get the short name of this background --form= bkgnd id ## or name
if word 2 of it is "id" then
put "No Name" into backgndName
else
put it into backgndName
end if
put "Script of Background " & i & ", " & "ID #" && the id of this bkgnd & " (" & backgndName & ")" & return after backScripts
get script of this bkgnd
if it is empty then put "No background script." & return into it
put it & return & deLim2 & return after backScripts -- end of bkgnd
if (the number of fields) <> 0 then readBackFields
else put "No background fields." & return & return after backScripts
if (the number of bkgnd buttons) <> 0 then readBackButtons
else put "No background buttons." & return & return after backScripts
put deLim1 & return after backScripts
-- marks end of bkgnds
end repeat --end of backgrounds
end readBackgrounds
on readCards
global targetStack,totalCards,totalBacks,targetLongName,thisStack
global cardScripts,deLim1,deLim2,targetShortName
--deLim1 marks the end of the card(s)
--deLim2 marks the end of the object inside the card(s)
go card 1 -- of target stack, natch
--============= getting the card scripts =================
repeat with i = 1 to (the number of cards)
cursorwatch
get the short name of this card -- form= card id # or name
if word 2 of it is "id" then
put "Script of Card Number " & i & ", " & "ID #" && (the short id of this card) & " (No Name)" & return after cardScripts
else
put "Script of Card Number " & i & ", " & "ID #" && (the short id of this card) & " (" & it & ")" & return after cardScripts
end if
get script of this card
if it is empty then put "No card script." & return into it
put it & return & deLim2 & return after cardScripts
if (the number of card fields) <> 0 then readCardFields
else put "No card fields." & return & return & deLim2 & return after cardScripts
-- put deLim2 & return after cardScripts
if (the number of card buttons) <> 0 then readCardButtons
else put "No card buttons." & return & deLim2 & return after cardScripts
put deLim1 & return after cardScripts --marks end of card
go next card -- meaning, we end up on card 1
end repeat -- end of cards
end readCards
on writeEm -- returning to Script Reader with the scripts
global targetStack,totalCards,totalBacks,targetLongName,thisStack
global backScripts,cardScripts,deLim1,deLim2,targetShortName
go thisStack
go last card
answer "Got the scripts. Want to watch (slower)?" with "Yes" or "No"
if it is "yes" then
set lockScreen to false
else
go card 2
set lockScreen to false
set cursor to 4
set lockScreen to true
go last card
end if
-- =================debugging only
--doMenu "New Card"
--put backScripts into field "scriptfield"
--doMenu "New Card"
--put cardScripts into field "scriptfield"
-- =================end of debugging **
writeBackScripts
writeCardScripts
end writeEm
on cleanUp
global thisStack
go card 2 of stack thisStack
set lockScreen to false
play flute
set lockMessages to false
answer "All done!"
visual dissolve
go next card -- the first card of the scripts
exit to hypercard
end cleanUp
-- A special thanks to Sioux Lacy for help with debugging and of course to Bill Atkinson for making it possible.
-- Thanks to John LeBourgeois for help with version 1.2
-- The “recorder” icons at the bottom of the Reader are by Tim Oren we only use three, but the full set is attached. Thanks, Tim.
on makeDelim
global targetStack,deLim1,deLim2,targetShortName
-- deLim1 marks the end of the background or card
-- deLim2 marks the end of any object script
cursorwatch
put "•" into deLim1
repeat 3
put char(random(the number of chars in targetShortName)) of targetShortName after deLim1
end repeat
put "•" after deLim1
put "••" into deLim2
repeat 3
put char(random(the number of chars in targetShortName)) of targetShortName after deLim2
end repeat
put "••" after deLim2
end makeDeLim
on readBackFields
-- ========= getting the background field scripts =========
global backScripts,deLim1,deLim2
repeat with j=1 to the number of fields --of the current bkgnd
if the visible of bkgnd field j is false then put " [hidden]" into showing
else put " [visible]" into showing
get the short name of field j --form= field id ## or name
if word 3 of it is "id" then
put return & "Script of Background field " & j & ", " & "ID #" && (the short id of this background) & " (No Name)" & showing & return after backScripts
else
put return & "Script of Background field " & j & ", " & "ID #" && (the short id of field j) & " (" & it & ")" & showing & return after backScripts
end if
cursorwatch
get script of field j
if it is empty then put "No script." & return into it
put it & return & deLim2 & return after backScripts -- end of field script
end repeat --end of background fields
end readBackFields
on readBackButtons
-- ============= getting the background button scripts =========
global backScripts,deLim2
repeat with k = 1 to (the number of bkgnd buttons)
if the visible of bkgnd button k is false then put " [hidden]" into showing
else put " [visible]" into showing
get the short name of bkgnd button k --form = bkgnd btn id # or name
if word 3 of it is "id" then
put return & "Script of Background button " & k & ", " & it & " (No Name)" & showing & return after backScripts
else
put return & "Script of Background button " & k & ", " & "ID #" && (the short id of bkgnd button k) & " (" & it & ")" & showing & return after backScripts
end if
cursorwatch
get script of bkgnd button k
if it is empty then put "No script." & return into it
put it & return & deLim2 & return after backScripts -- end of button script
if the visible of card field j is false then put " [hidden]" into showing
else put " [visible]" into showing
get the short name of card field j --form= card fld id # or name
if word 3 of it is "id" then
put return & "Script of Card Field Number " & j & ", " & it & " (No name)" & showing & return after cardScripts
else
put return & "Script of Card Field Number " & j & ", " & "ID #" && (the short id of card field j) & " (" & it & ")" & showing & return after cardScripts
end if
cursorwatch
get script of card field j
if it is empty then put "No script." & return & return into it
put it & return & deLim2 & return after cardScripts